import 'package:flutter/material.dart';

class ListView1 extends StatelessWidget {
  const ListView1({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView(
          children: [
            ListTile(
              leading: Icon(Icons.ac_unit), // 左侧组件
              title: Text("我是主标题"), // 标题
              // 副标题
              subtitle: Text(
                  "subTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitlesubTitle"),
              trailing: Icon(Icons.access_alarm), // 右侧组件
              isThreeLine: true, // 是否三行，其实没啥用，但是设置为 true 时，subTitle 不可以为空
              dense: false, // 是否使用缩小布局
              visualDensity: VisualDensity(horizontal: -4), // 紧凑程度
              contentPadding: EdgeInsets.all(20), // content 内间距
              enabled: true, // 是否可用，仅改变颜色
              // 点击事件回调
              onTap: () {
                print("onTap");
              },
              // 长按事件回调
              onLongPress: () {
                print("onLongPress");
              },
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
              leading: Image.network(
                  'https://wx4.sinaimg.cn/mw690/006xNaGDly1hkq68v8bbjj32lr4moe86.jpg'),
              trailing: Image.network(
                  'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201507%2F17%2F20150717210445_ETZFu.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1704980124&t=3603ad3d1c831f3f8487991d42f955a7'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
              leading: ClipOval(
                // child: Image.asset("images/avatar.png",
                // child: Image.asset("images/002.jpg",
                child: Image.network(
                    "https://5b0988e595225.cdn.sohucs.com/images/20190424/88889d3ea3ec4d12a64ed6ae449d4255.jpeg",
                    width: 50,
                    height: 50,
                    fit: BoxFit.cover),
              ),
              trailing: Icon(
                Icons.arrow_forward,
                color: Colors.grey,
                size: 40,
                textDirection: TextDirection.ltr,
              ),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            ),
            Divider(),
            ListTile(
              title: Text(' 我是一个item'),
            )
          ],
        ),
      ),
    );
  }
}

class ListView2 extends StatelessWidget {
  const ListView2({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView(
          children: const <Widget>[
            ListTile(leading: Icon(Icons.home), title: Text("首页")),
            Divider(),
            ListTile(
              leading: Icon(Icons.assignment, color: Colors.red),
              title: Text("全部订单"),
            ),
            Divider(),
            ListTile(
              leading: Icon(Icons.payment, color: Colors.green),
              title: Text("待付款"),
            ),
            ListTile(
              leading: Icon(Icons.favorite, color: Colors.lightGreen),
              title: Text("我的收藏"),
              trailing: Icon(Icons.chevron_right_sharp),
            ),
            Divider(),
            ListTile(
              leading: Icon(Icons.people, color: Colors.black54),
              title: Text("在线客服"),
              trailing: Icon(Icons.chevron_right_sharp),
            ),
            Divider(),
          ],
        ),
      ),
    );
  }
}

class ListView3 extends StatelessWidget {
  const ListView3({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(),
            body: Container(
              height: 100,
              child: ListView(
                padding: const EdgeInsets.all(0),
                scrollDirection: Axis.horizontal,
                children: <Widget>[
                  Container(
                    height: 120,
                    width: 120, //宽度是自适应的    设置没有效果
                    decoration: const BoxDecoration(color: Colors.red),
                  ),
                  Container(
                    height: 120,
                    width: 120,
                    decoration: const BoxDecoration(color: Colors.yellow),
                  ),
                  Container(
                    height: 120,
                    decoration: const BoxDecoration(color: Colors.orange),
                  ),
                  Container(
                    height: 120,
                    decoration: const BoxDecoration(color: Colors.black),
                  ),
                  Container(
                    height: 120,
                    decoration: const BoxDecoration(color: Colors.blue),
                  ),
                  Container(
                    height: 120,
                    decoration: const BoxDecoration(color: Colors.red),
                  ),
                  Container(
                    height: 120,
                    decoration: const BoxDecoration(color: Colors.pink),
                  ),
                  Container(
                    height: 120,
                    decoration: const BoxDecoration(color: Colors.blueGrey),
                  ),
                ],
              ),
            )));
  }
}
